<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8">
<script
	src="${basePath}commentResources/jquery-1.12.4/jquery-1.12.4.min.js"></script>

<script type="text/javascript">
	//在全局定义验证码    
	var code;
	//产生验证码     
	window.onload = function() {
		createCode();
	}
	function createCode() {
		code = "";
		//验证码的长度
		var codeLength = 5;
		var checkCode = document.getElementById("checkCode");
		//随机数
		var random = new Array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 'A', 'B', 'C',
				'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
				'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a',
				'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j');
		//循环操作     
		for (var i = 0; i < codeLength; i++) {
			//取得随机数的索引 
			var charIndex = Math.floor(Math.random() * 36);
			//根据索引取得随机数加到code上
			code += random[charIndex];
		}
		//把code值赋给验证码
		checkCode.value = code;
	}
	//校验验证码     
	function validate() {

		//所有验证是否全部通过标识
		var isOk = true;
		//验证用户名不能为空
		//获取用户名控件对象
		var strNumber = $("#textName").val();
		//验证不通过
		if (strNumber == null || strNumber == "") {
			//显示提示信息
			$("#textNumMsg").html("请输入用户名");
			//修改验证通过标识
			isOk = false;
		} else {
			//验证通过
			$("#textNumMsg").html("");
		}
		//验证密码不能为空
		//获取密码控件对象
		var strtextPsw = $("#textPsw").val();
		//验证不通过
		if (strtextPsw == null || strtextPsw == "") {
			//显示提示信息
			$("#textPswMsg").html("请输入密码");
			//修改验证通过标识
			isOk = false;
		} else {
			//验证通过
			$("#textPswMsg").html("");
		}
		//取得输入的验证码并转化为大写  
		var inputCode = $("#textValidate").val().toUpperCase();
		//若输入的验证码长度为0
		if (inputCode.length <= 0) {
			//则弹出请输入验证码   
			$("#textValidateMsg").html("请输入验证码");

			isOk = false;
			//若输入的验证码与产生的验证码不一致时
		} else if (inputCode != code) {
			//则弹出验证码输入错误 
			$("#textValidateMsg").html("验证码输入错误！请重新输入验证码");
			//如果输入验证码错误 刷新验证码
			createCode();
			isOk = false;

		} else {
			//验证通过
			$("#textValidateMsg").html("");
			//输入验证码正确 返回true 登陆成功
			isOk = true;
		}
		return isOk;
	}
</script>
<style type="text/css">
    .code
     {
	      font-family: Arial;
	      font-style: italic;
	      color: blue;
	      border: 0;
	      padding: 2px 3px;
	      letter-spacing: 3px;
	      font-weight: bolder;
	    
}

    .unchanged
     {
	      border: 0;
	    
}
body{
background-image: url(commentResources/loginResource/images/hh0.jpg);
 background-size:cover; 
}
  
</style>
<title>登录</title>
</head>
<body>

	<p align="center">
		<font face="隶书" color="#00DB00" size="20">WellcomeTo郴电国际收费系统</font>
	</p>
	<form class="form-horizontal" action="${basePath}login" method="post">
	<div class="form-group" align="right">
	<label for="inputEmail3" class="col-sm-2 control-label"><font
				color="green">天气预报</font></label>
				<div > 
				<iframe name="sinaWeatherTool" src="http://weather.news.sina.com.cn/chajian/iframe/weatherStyle31.html?city=%E5%A4%A9%E6%B4%A5" 
				width="160" height="150" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no">
				</iframe>
				</div>
	</div>
		<div class="form-group" align="center">
			<label for="inputEmail3" class="col-sm-2 control-label"><font
				color="blue">用户名</font></label>
			<div class="col-sm-10">
				<input type="text" class="form-control" id="textName"
					name="textName" placeholder="Number">
			</div>
			<label> <font color="red" id="textNumMsg"></font>
			</label>
		</div>
		<div class="form-group" align="center">
			<label for="inputPassword3" class="col-sm-2 control-label"><font
				color="blue">密码</font></label>
			<div class="col-sm-10">
				<input type="password" class="form-control" id="textPsw"
					name="textPsw" placeholder="Password">
			</div>
			<label> <font id="textPswMsg" color="red"></font>
			</label>
		</div>
		<div class="form-group" align="center">
			<label for="inputUser" class="col-sm-2 control-label"><font
				color="blue">用户类型</font></label>
			<div class="col-sm-4">
				<select class="form-control" id="user" name="user">
					<option value=""></option>
					<option value="1">管理员</option>
					<option value="2">操作员</option>
					<option value="3">用户</option>
				</select>
			</div>
		</div>
		<div align="center">
			<label class="control-label" for="inputEmail"><font
				color="blue">验证码</font></label> <br /> <input type="text" id="textValidate" />
			<br /> <label> <font id="textValidateMsg" color="red"></font>
			</label> <br /> <input type="text" readonly="readonly" id="checkCode"
				class="unchanged"
				style="width: 80px; background: grey; opacity: 0.7;" /> <a href="#"
				onclick="createCode()"><font color="green">看不清</font></a>
		</div>
		<div class="form-group" align="center">
			<div class="col-sm-offset-2 col-sm-10">
				<button type="submit" class="btn btn-default"
					onclick=" return validate()">
					<font color="blue">登录</font>
				</button>
				<a href="regist.jsp"><font color="blue">注册</font></a>

			</div>
		</div>
	</form>

</body>
</html>
